package org.anupta.game.server.game.client;

import org.anupta.game.entity.entities.Account;
import org.anupta.game.entity.entities.Player;
import org.anupta.game.main.Main;
import org.anupta.game.server.game.packet.hello.HelloGame;
import org.apache.mina.core.session.IoSession;

public class GameClient {
	private IoSession session = null;
	private GameParser parser = null;
	private String hash = null;
	private Account account = null;
	private Player player = null;
	
	public GameClient(IoSession session){
		setSession(session);
		setParser(new GameParser(this));
		new HelloGame(this);
	}
	
	public void parse(String message){
		try{
		parser.parse(message);
		}catch(Exception e){
			Main.err.write(e);
		}
	}
	
	public void quit(){
		//TODO: Kick all player
		session.close(true);
	}
	public void timeOut(){
		session.close(true);
	}

	public IoSession getSession() {
		return session;
	}

	public void setSession(IoSession session) {
		this.session = session;
	}

	public GameParser getParser() {
		return parser;
	}

	public void setParser(GameParser parser) {
		this.parser = parser;
	}
	
	public String getIp(){
		return session.getRemoteAddress().toString();
	}
	
	public void send(String packet){
		session.write(packet);
	}

	public String getHash() {
		return hash;
	}

	public void setHash(String hash) {
		this.hash = hash;
	}

	public Account getAccount() {
		return account;
	}

	public void setAccount(Account account) {
		this.account = account;
	}

	public Player getPlayer() {
		return player;
	}

	public void setPlayer(Player player) {
		this.player = player;
	}
}
